//
//  GYStoreHomeFirstCell.m
//  GoodLuck
//
//  Created by apple on 2018/3/13.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

#import "GYStoreHomeFirstCell.h"
#import "GYSearchGoos.h"
@interface GYStoreHomeFirstCell ()

@property (weak, nonatomic) IBOutlet UIImageView *firstImageView;
@property (weak, nonatomic) IBOutlet UILabel *firstNumLable;
@property (weak, nonatomic) IBOutlet UILabel *firstPriceLable;
@property (weak, nonatomic) IBOutlet UIImageView *secondImageView;
@property (weak, nonatomic) IBOutlet UILabel *sencondNumLable;
@property (weak, nonatomic) IBOutlet UILabel *sencodePriceLable;

@end
@implementation GYStoreHomeFirstCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (IBAction)onClick:(UIButton *)sender {
    if (self.models.count != 0) {
        self.shopDetailsViewCallBack(sender.tag);        
    }
}


- (void)setModels:(NSArray *)models {
    _models = models;
    if (models.count == 0) {
        self.firstImageView.hidden = YES;
        self.firstNumLable.hidden = YES;
        self.firstPriceLable.hidden = YES;
        self.secondImageView.hidden = YES;
        self.sencondNumLable.hidden = YES;
        self.sencodePriceLable.hidden = YES;
    }else {
        self.firstImageView.hidden = NO;
        self.firstNumLable.hidden = NO;
        self.firstPriceLable.hidden = NO;
        self.secondImageView.hidden = NO;
        self.sencondNumLable.hidden = NO;
        self.sencodePriceLable.hidden = NO;
    }
    
    for (int i =0; i<models.count; i++) {
        GYSearchGoos *goods = models[i];
        switch (i) {
            case 0:
            {
                [self.firstImageView sd_setImageWithURL:[NSURL URLWithString:goods.goods_image_url] placeholderImage:[UIImage imageNamed:@"4"]];
                self.firstNumLable.text = [NSString stringWithFormat:@"已售%@",goods.goods_salenum];
                self.firstPriceLable.text = [NSString stringWithFormat:@"¥%@",goods.goods_price];
            }
                break;
                
            case 1:
            {
                [self.secondImageView sd_setImageWithURL:[NSURL URLWithString:goods.goods_image_url] placeholderImage:[UIImage imageNamed:@"4"]];
                self.sencondNumLable.text = [NSString stringWithFormat:@"已售%@",goods.goods_salenum];
                self.sencodePriceLable.text = [NSString stringWithFormat:@"¥%@",goods.goods_price];
            }
                break;
                
            default:
                break;
        }
    }
}


@end
